-
Notifications
You must be signed in to change notification settings - Fork 34
[PLUGIN-1824] ErrorDetailsProvider - MySql Source/Sink plugin #523
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| if (sourceConfig.canConnect()) { | ||
| try { | ||
| stageConfigurer.setOutputSchema(getSchema(driverClass)); | ||
| stageConfigurer.setOutputSchema(getSchema(driverClass, collector)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we are already adding the exception in failure collector below by catching it, why is this extra step needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also can you please add sql state and error code in the message on line 127?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added SQL error details.
b755515 to
84432d6
Compare
| return ErrorUtils.getProgramFailureException(new ErrorCategory(ErrorCategory.ErrorCategoryEnum.PLUGIN), | ||
| errorMessage, | ||
| String.format(errorMessageFormat, errorContext.getPhase(), errorMessage), ErrorType.SYSTEM, false, e); | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed !
itsankit-google
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add open and capture logs step in the e2e tests where pipeline also fails so that we can verify the expected logs?
for example:
database-plugins/mysql-plugin/src/e2e-test/features/mysqlsource/RunTimeWithMacros.feature
Line 207 in 91d0ff7
| Scenario: Verify that pipeline fails when user provides invalid Credentials for connection with Macros |
| if (t instanceof IllegalStateException) { | ||
| return getProgramFailureException((IllegalStateException) t, errorContext); | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: remove empty line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed !
| * | ||
| * @return The external documentation link as a {@link String}. | ||
| */ | ||
| protected String getExternalDocumentationLink() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
where is this method used in this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is how it is used in google-cloud plugin:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh ! This makes sense, I though this will be called by the platform and display on UI.
I have added the doc link in error details now !
| protected ErrorType getErrorTypeFromErrorCode(int errorCode) { | ||
| // https://dev.mysql.com/doc/refman/9.0/en/error-message-elements.html#error-code-ranges | ||
| if (errorCode >= 1000 && errorCode <= 1999 || errorCode >= 2000 && errorCode <= 2999 || | ||
| errorCode >= 3000 && errorCode <= 4999 || errorCode >= 5000 && errorCode <= 5999) { | ||
| return ErrorType.USER; | ||
| } else if (errorCode >= 10000 && errorCode <= 49999 || errorCode >= 50000 && errorCode <= 51999) { | ||
| return ErrorType.SYSTEM; | ||
| } else { | ||
| return ErrorType.UNKNOWN; | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It can be made more readable, something like this:
protected ErrorType getErrorTypeFromErrorCode(int errorCode) {
// https://dev.mysql.com/doc/refman/9.0/en/error-message-elements.html#error-code-ranges
// USER errors: General errors, server-specific, storage engine, and third-party engine errors
if (errorCode >= 1000 && errorCode <= 5999) {
return ErrorType.USER;
}
// SYSTEM errors: Enterprise and user-defined custom error messages
else if (errorCode >= 10000 && errorCode <= 51999) {
return ErrorType.SYSTEM;
}
// UNKNOWN errors: Anything outside defined ranges
else {
return ErrorType.UNKNOWN;
}
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated !
| And Run the Pipeline in Runtime with runtime arguments | ||
| Then Wait till pipeline is in running state | ||
| Then Open and capture logs | ||
| And Open and capture logs |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this step looks duplicate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed dupe !
| addOutputContext(context); | ||
|
|
||
| // set error details provider | ||
| context.setErrorDetailsProvider(new ErrorDetailsProviderSpec(getErrorDetailsProviderClassName())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context.setErrorDetailsProvider should be called before addOutputContext(context) is called.
Otherwise error details provider information is not propagated to platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Understood, moved !
| DataDrivenETLDBInputFormat.class, connectionConfigAccessor.getConfiguration()))); | ||
|
|
||
| // set error details provider | ||
| context.setErrorDetailsProvider(new ErrorDetailsProviderSpec(getErrorDetailsProviderClassName())); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
similarly here:
context.setErrorDetailsProvider should be called before context.setInput(Input.of(sourceConfig.getReferenceName(), new SourceInputFormatProvider( DataDrivenETLDBInputFormat.class, connectionConfigAccessor.getConfiguration()))) is called.
Otherwise error details provider information is not propagated to platform.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved !
|
Please squash the commits before merge. |
ErrorDetailsProvider - MySql [Source|Sink] plugin
Jira : PLUGIN-1824
Description
Implement Program Failure Exception Handling in MySql Source/Sink plugin to catch known errors
Code change
DBErrorDetailsProvider.javaMysqlErrorDetailsProvider.javaDBRecord.javaAbstractDBSink.javaAbstractDBSource.javaMysqlConstants.javaMysqlSink.javaMysqlSource.javaMysqlUtil.java